home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Text / Sort Digests folder / Sort Digests ReadMe < prev   
Text File  |  1995-05-30  |  8KB  |  88 lines

  1. Sort Digests script
  2. by Paul L. Suh
  3.  
  4.  
  5. Basic description
  6.  
  7. This script will sort files into pre-specified folders based on their names. You can use it either by dropping files onto it, or by letting it idle in the background and watch a particular folder. 
  8.  
  9. I wrote this because it is convenient for me to have all of the various files that I download or save go into a particular folder, called appropriately enough “New Downloads.” Among the items that go in there are MacScript mailing list digests, Info-Mac Digests, Mac*Chat, TidBITS, and Mac-Lawyers mailing list digests. I used to move these by hand to the appropriate folders for view with Easy-view, but I got tired of that. So, I wrote this script. 
  10.  
  11. I call it “Sort Digests,” but it could be used to handle lots of other tasks which involve moving files to the right place based on their names or perhaps other characteristics. 
  12.  
  13. The sorting process
  14.  
  15. The sorting process revolves what I call “links.” Each link has a key string, such as “Info-Mac” or “TidBITS,” and a destination folder for files that match the key string. The script looks at the name of each file that it processes and checks to see if it contains the key string. If it does, then the file is moved to the destination folder for that link. 
  16.  
  17. Set-up
  18.  
  19. This script uses the Choose File, Display Dialog, File Commands, and Read/Write Commands OSAXes supplied by Apple, the Jon’s Commands OSAX by Jon Pugh, and the Scriptable Finder. Just about everyone with System 7.5 should have these installed automatically, so I haven’t bothered to check for their presence. I deliberately avoided using most third-party OSAXes to make this script as portable as possible. 
  20.  
  21. Although the script is usable without the Jon’s Commands OSAX, it can only handle one link and cannot be easily reconfigured. If you are using scripts to any extent, you should install this free package. It can be downloaded from an info-mac mirror or from the AppleScripts FTP site at gaea. The current version at this writing is 1.3.5. The URLs are: 
  22.  
  23. /info-mac/dev/src/jons-commands-135-osax.hqx
  24. <ftp://gaea.kgs.ukans.edu/applescript/osaxen/JonsCommands135.sit.hqx>
  25.  
  26. Before you use this script, you must first specify at least one key string for the script to watch for. You can do this one of two ways: 
  27.  
  28. 1) You can drop an example file or a group of files onto the droplet with the option key held down. For each example file, this will bring up a dialog containing the first eight letters of the name of the sample file as a proposed key string, which you can then edit. After clicking OK, you will be asked to choose a folder as the destination for files with that key. Any files whose names contain the key string will be moved to the folder you specified. 
  29.  
  30. 2) You can double-click on the script. This will automatically bring up dialogs asking for a folder to watch in idle mode, a key string, and a destination folder for the key. 
  31.  
  32. Using Sort Digests as a droplet
  33.  
  34. You can use the script as a droplet by just dropping files onto it. If you drop a file or group of files, it will check each file against the list of keys, and if there a match, move the file to the designated folder. 
  35.  
  36. Using Sort Digests in idle mode
  37.  
  38. Run the script by double-clicking it. The first time you run it, the script will ask you to select a folder to be monitored as well as a first key string and destination. Thereafter, the script will monitor the folder that you have chosen by lurking in the background and watching every 15 minutes for new files. If it finds a file that matches one of the keys that you have chosen, it will move that file to the destination folder for that key. (You can change the 15 minutes by changing the “TimeToSleep” property in the script.)
  39.  
  40. You can change the folder that the script watches by either dropping a single folder on the droplet with the option key held down, or by double-clicking the droplet with the command key held down and selecting “Change folder…” from thedialog that shows up. 
  41.  
  42. Editing links (not yet implemented; see below for a crude editing method)
  43.  
  44. Command double-clicking the droplet and clicking on “Edit Keys…” brings up a list of keys that are in the script. You can change the key, change the destination folder for that key, or delete the key. 
  45.  
  46. Getting a list of links and the folder watched
  47.  
  48. This was actually part of my debugging code, to see if things option-dropped on the script worked, but I decided to include it as part of the finished product anyway since the Editing Links part is still not yet impletmented. 
  49.  
  50. To get a list of links and the folder that is watched, drop a file named “Get links” of type ‘TEXT’ onto the script. The contents of the file will be erased, and a tab delimited list of keys and destinations will be put into the file. The last line of the file will be the folder to watch. 
  51.  
  52. To set the links, drop a file named “Set links” of type ‘TEXT’ on the script. It should have exactly the same format as the “Get links” file. The current list of links will be replaced by the one specified in the “Set links” file, and the folder watched will be changed as well. If you don’t want a watched folder, change the path on the last line to the string “none”. 
  53.  
  54. This allows you to save a list of your links in the event that you want to edit your copy of the script, and then restore them afterwards. It also allows you to delete a link that you no longer want. 
  55.  
  56. Action summary
  57.  
  58. Drop files — filter the files
  59. Option-drop files — use the files as examples to create keys
  60. Option-drop folder — set the background folder
  61. Double-click — run the script in the background
  62. Command double-click — select the background folder, create a new key, or edit existing keys. 
  63. Command drop “Get links” or “Set links” — get or set the list of links
  64.  
  65. Future plans
  66.  
  67. I wrote this partly for my own use and also partly to as a learning exercise. As part of the learning exercise, I intend to turn this from the procedural-style implementation that I have now into an object-oriented set of sources. This will allow inheritance and overriding of inherited functions to play a role in allowing the script to sort on criteria other than just the file name. Some that spring to mind are modification date, size, or file suffix, such as .c or .h. Beyond that, I think that it might be nice to make both the sorting and the processing attachable, so that to determine which files to handle you could attach a separate script and you could also have a script that does something more to the files than just move them to another folder. 
  68.  
  69. If and when I get around to buying Facespan, I’ll use it to implement the user interface for editing links. 
  70.  
  71. Acknowledgements
  72.  
  73. I wrote this script by starting from the Alert When Folder Changes script supplied by Apple in System 7.5. However, by now I don’t think there is any of the original code remaining. 
  74.  
  75. I’d like to thank Jon Pugh and Gregory Charles Rivers in particular, and all of the other good folks on the MACSCRPT mailing list in general, for answering my dumb-ass questions. 
  76.  
  77. Version history
  78.  
  79. 0.1.1 (5/30/95) -- found a bug all by myself. Really more of a bug in the ReadMe than anything else. Changed ReadMe to talk about Jon’s Commands and added a little code at initialization to check for its presence. 
  80.  
  81. 0.1 (5/26/95) -- my first release, and I hope there are no bugs. 
  82.  
  83. Plain language legal stuff
  84.  
  85. Please be sure to distribute this ReadMe file along with the script. 
  86.  
  87. This script is copyright ©1995 by Paul L. Suh. Using the script and modifying it for your own personal use is free. User groups and other non-profit organizations may charge nominal duplication fees for distributing copies of this script. On-line services may charge normal connect time fees for downloading this script. If you want to use this script as part of a solution in a consulting engagement, contact me first; I’ll probably say OK, but I’d appreciate being asked beforehand. Selling this script for profit, either on its own or as part of a collection, is expressly prohibited. If this script goes and trashes your life’s work just before you make a backup, I'm sorry, but you were warned. I assume no responsibility. Besides, you got this for free, right? 
  88.